﻿using Gonte.Reflection;

namespace Gonte.Workflow.Tasks
{
    public class SetProperty
        : GetAccessor
    {
        public override TaskResult Execute(TaskContext context)
        {
            TaskResult result = base.Execute(context);
            TypeAccessor typeAccessor = (TypeAccessor)result.Value;
            object data = result.AditionalValues[Data];

            result = _from.Execute(context);
            object value = result.Value;
            typeAccessor.SetValue(data, _property, value);

            return null;
        }

        private ITask _from;

        public ITask From
        {
            get { return _from; }
            set { _from = value; }
        }
    }
}
